package net.lengwang.iot.middleware.gateway;

public enum GatewayType {
    
    SGAla(0x59, "SGAla-网关"),
    M1_TEMPERATURE_HUMIDITY(0x51, "M1无线温湿度记录仪"),
    M2_TEMPERATURE(0x57, "M2无线温度记录仪"),
    M30_CO2_SENSOR(0x78, "M30二氧化碳传感器"),
    AO2_OXYGEN_SENSOR(0x7A, "AO2氧气传感器"),
    SK_LOCK(0x65, "电子锁SK"),
    M40_PRESSURE(0x75, "M40压差传感器"),
    L1_SENSOR(0x63, "L1系列传感器");

    private final int code;
    private final String description;

    GatewayType(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    // 根据编码查找对应的设备类型
    public static GatewayType fromCode(int code) {
        for (GatewayType type : GatewayType.values()) {
            if (type.code == code) {
                return type;
            }
        }
        throw new IllegalArgumentException("未知的设备类型编码: " + code);
    }
}